/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ares.service.action;

import com.ares.service.bean.BeanAcciones;
import com.ares.service.bean.BeanFormulario;
import com.ares.service.bean.BeanMovilidad;

import java.io.IOException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author electro
 */
public class ImprimirPlanAccion extends HttpServlet {
   
    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        System.out.println("Se imprimio el Plan de Accion");
    }

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            Document document = new Document(PageSize.A4);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PdfWriter.getInstance(document, baos);
            document.open();
            document.add(createTitulo("  GESTIÓN DE DESEMPEÑO", " PLAN DE ACCIÓN"));
            document.add(createCabeceraEvaluacionIntegral(request));

            try {
                document.add(createDetallePlanAccion(request));
            } catch (Exception ex) {
                Logger.getLogger(ImprimirPlanAccion.class.getName()).log(Level.SEVERE, null, ex);
            }

            document.add(createCondiciones());
            document.close();

            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control",
                    "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            response.setContentType("application/pdf");
            response.setContentLength(baos.size());
            OutputStream os = response.getOutputStream();
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (DocumentException ex) {
            throw new IOException(ex.getMessage());
        }
    }

    public PdfPTable createTitulo(String titulo, String dtTitulo) throws DocumentException {
        PdfPTable table = new PdfPTable(4);
        table.setWidths(new int[]{3, 7, 3, 7});
        table.setWidthPercentage(100);

        PdfPCell cell;

        Font font = new Font(CreateFont(), 10, Font.NORMAL, BaseColor.WHITE);

        cell = new PdfPCell(new Phrase(String.format(
                "%s", titulo), font));
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setBackgroundColor(new BaseColor(0, 0, 0));
        cell.setColspan(4);
        cell.setFixedHeight(32f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setBackgroundColor(new BaseColor(178, 178, 176));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setColspan(4);
        cell.setFixedHeight(4f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setBackgroundColor(new BaseColor(249, 184, 20));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setColspan(4);
        cell.setFixedHeight(4f);
        table.addCell(cell);

        font = new Font(CreateFont(), 8, Font.NORMAL, BaseColor.WHITE);
        cell = new PdfPCell(new Phrase(String.format("%s", dtTitulo), font));
        cell.setBackgroundColor(new BaseColor(0, 0, 0));
        cell.setColspan(4);
        cell.setFixedHeight(16f);
        table.addCell(cell);

        return table;
    }

    public BaseFont CreateFont() {
        BaseFont arial = null;
        String fs = File.separator;
        String ruta = getServletContext().getRealPath(fs);

        try {
            arial = BaseFont.createFont(
                    ruta + "fuente" + fs + "arial.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return arial;
    }

    public PdfPTable createCabeceraEvaluacionIntegral(HttpServletRequest request) throws DocumentException {
        HttpSession session = request.getSession();
        BeanFormulario formulario = (BeanFormulario) session.getAttribute("formulario");
        PdfPTable table = new PdfPTable(4);
        table.setWidths(new int[]{2, 7, 2, 7});
        table.setWidthPercentage(100);
        table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

        PdfPCell cell;

        Font font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("Evaluado :", font));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        Font font2 = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase(formulario.getStrNom_Empleado()+" "+formulario.getStrApellido_Empleado(), font2));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Evaluador :", font));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(formulario.getStrNom_Evaluador(), font2));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        //SEGUNDA FILA
        cell = new PdfPCell(new Phrase("Puesto :", font));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(formulario.getStrPuesto_Empleado(), font2));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Puesto :", font));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(formulario.getStrPuesto_Evaluador(), font2));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        //TERCERA FILA
        cell = new PdfPCell(new Phrase("Área :", font));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(formulario.getStrArea_Empleado(), font2));
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("", font));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setColspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setColspan(4);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setFixedHeight(10f);
        table.addCell(cell);
        
        return table;
    }

    public PdfPTable createCondiciones() throws DocumentException {
        PdfPTable table = new PdfPTable(2);
        table.setWidths(new int[]{1, 3});
        table.setWidthPercentage(35);
        table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

        PdfPCell cell;
        Font font = new Font(CreateFont(), 8, Font.NORMAL, BaseColor.BLACK);

        cell = new PdfPCell(new Phrase(""));
        cell.setColspan(2);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setFixedHeight(30f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Firma del Colaborador:", font));
        cell.setColspan(2);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setFixedHeight(20f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Firma del Jefe Directo:", font));
        cell.setColspan(2);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setFixedHeight(20f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Firma del Revisor:", font));
        cell.setColspan(2);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setFixedHeight(20f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setColspan(2);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setFixedHeight(30f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Plan de Acción evaluado y discutido el: __/__/__", font));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setColspan(4);
        table.addCell(cell);

        return table;
    }

    public PdfPTable createDetallePlanAccion(HttpServletRequest request) throws DocumentException, Exception {
        HttpSession session = request.getSession();
        String fs = File.separator;
        String ruta = getServletContext().getRealPath(fs);
        String tipoMovilidad; //si es S= Si, si es N=NO
        BeanAcciones beanAcciones = (BeanAcciones) session.getAttribute("beanAcciones");
        BeanMovilidad beanMovilidad = (BeanMovilidad) session.getAttribute("movilidad");
        PdfPTable table = new PdfPTable(2);
        table.setWidths(new int[]{1, 30});
        table.setWidthPercentage(100);

        PdfPCell cell;
        Font font;

      //ASPECTOS A DESARROLLAR
        font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("Aspectos a Desarrollar (En base a Evaluación de Desempeño actual y Proyectos futuros)", font));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(249, 184, 20));
        table.addCell(cell);

        font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("1.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getObjDesarrollo1()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("2.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getObjDesarrollo2()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("3.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getObjDesarrollo3()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);

      //ACCIONES A TOMAR
        font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("Acciones a tomar: (Ejemplos: formación en: habilidades de gestión, idiomas, conocimientos del negocio y la industria, "
                + "conocimientos técnicos; equipos especiales de trabajo; traslados y rotaciones, etc.)", font));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(249, 184, 20));
        table.addCell(cell);

        font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("1.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getAspDesarrollo1()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("2.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getAspDesarrollo2()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("3.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getAspDesarrollo3()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);

        //INTERESES Y ADVERSIONES DE CARRERA
        font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("Intereses y Aversiones de Carrera (Responda a las aspiraciones del colaborador, por ejemplo: crecer en el área " +
        		"actual o cambiar de área, qué área no le interesaría conocer)", font));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(249, 184, 20));
        table.addCell(cell);

        font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("1.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getEjeAccion1()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("2.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + validarTexto(beanAcciones.getEjeAccion2()), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);
    	/*
        cell = new PdfPCell(new Phrase("3.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("" + beanAcciones.getEjeAccion3(), font));
        cell.setBackgroundColor(new BaseColor(255, 255, 255));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED);
        table.addCell(cell);
        */

        //MOVILIDAD
        font = new Font(CreateFont(), 7, Font.NORMAL, BaseColor.BLACK);
        cell = new PdfPCell(new Phrase("Movilidad", font));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(249, 184, 20));
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("1.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

		//PRUEBA
        PdfPTable tableaAux = new PdfPTable(1);
        tableaAux.setWidths(new int[]{1});
        tableaAux.setWidthPercentage(100);

        PdfPCell cellAux;
        //Ingreso la primera fila
        cellAux = new PdfPCell(new Phrase("Movilidad a Unidad Operativa1", font));
        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cellAux.setBorder(PdfPCell.NO_BORDER);
        //cellAux.setColspan(4);
        tableaAux.addCell(cellAux);
/*
        if(beanMovilidad.getMovilidadUnidadOperativa().equals("S")) tipoMovilidad = "SI";
        	else tipoMovilidad = "NO";
        
        cellAux = new PdfPCell(new Phrase(tipoMovilidad, font));
        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellAux.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cellAux.setBorder(PdfPCell.NO_BORDER);
        tableaAux.addCell(cellAux);
*/
        try {
        	if(beanMovilidad.getMovilidadUnidadOperativa().equals("S")){
	            Image foto1 = Image.getInstance(ruta + "images" + fs + "seleccionadoSI.jpg");
	            foto1.scalePercent(50.0f);
	            //PARA CENTRAR LA IMAGEN
	            foto1.setAlignment(Image.ALIGN_LEFT);
	            cellAux = new PdfPCell();
	            cellAux.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
	            cellAux.setBorder(PdfPCell.NO_BORDER);
	            cellAux.addElement(foto1);
	            tableaAux.addCell(cellAux);
        	}
        	else{
            	if(beanMovilidad.getMovilidadUnidadOperativa().equals("N")){
    	            Image foto1 = Image.getInstance(ruta + "images" + fs + "seleccionadoNO.jpg");
    	            foto1.scalePercent(50.0f);
    	            //PARA CENTRAR LA IMAGEN
    	            foto1.setAlignment(Image.ALIGN_LEFT);
    	            cellAux = new PdfPCell();
    	            cellAux.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    	            cellAux.setBorder(PdfPCell.NO_BORDER);
    	            cellAux.addElement(foto1);
    	            tableaAux.addCell(cellAux);
            	}	
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }

	        cellAux = new PdfPCell(new Phrase("Preferencias:", font));
	        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
	        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
	        cellAux.setBorder(PdfPCell.NO_BORDER);
	        tableaAux.addCell(cellAux);
	
	        cellAux = new PdfPCell(new Phrase(validarTexto(beanMovilidad.getPreferenciaUnidadOperativa()), font));
	        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
	        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
	        cellAux.setBorder(PdfPCell.NO_BORDER);
	        tableaAux.addCell(cellAux);

        
        table.addCell(tableaAux);

		//PRUEBA        

        cell = new PdfPCell(new Phrase("2.", font));
        cell.setBackgroundColor(new BaseColor(228, 228, 228));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        PdfPTable tableaAux1 = new PdfPTable(1);
        tableaAux1.setWidths(new int[]{1});
        tableaAux1.setWidthPercentage(100);

        cellAux = new PdfPCell(new Phrase("Movilidad a Otro País", font));
        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cellAux.setBorder(PdfPCell.NO_BORDER);
        tableaAux1.addCell(cellAux);
/*
        if(beanMovilidad.getMovilidadPais().equals("S")) tipoMovilidad = "SI";
    	else tipoMovilidad = "NO";
        
        cellAux = new PdfPCell(new Phrase(tipoMovilidad, font));
        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellAux.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cellAux.setBorder(PdfPCell.NO_BORDER);
        tableaAux1.addCell(cellAux);
*/
        try {
        	if(beanMovilidad.getMovilidadPais().equals("S")){
	            Image foto1 = Image.getInstance(ruta + "images" + fs + "seleccionadoSI.jpg");
	            foto1.scalePercent(50.0f);
	            //PARA CENTRAR LA IMAGEN
	            foto1.setAlignment(Image.ALIGN_LEFT);
	            cellAux = new PdfPCell();
	            cellAux.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
	            cellAux.setBorder(PdfPCell.NO_BORDER);
	            cellAux.addElement(foto1);
	            tableaAux1.addCell(cellAux);
        	}
        	else{
            	if(beanMovilidad.getMovilidadPais().equals("N")){
    	            Image foto1 = Image.getInstance(ruta + "images" + fs + "seleccionadoNO.jpg");
    	            foto1.scalePercent(50.0f);
    	            //PARA CENTRAR LA IMAGEN
    	            foto1.setAlignment(Image.ALIGN_LEFT);
    	            cellAux = new PdfPCell();
    	            cellAux.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    	            cellAux.setBorder(PdfPCell.NO_BORDER);
    	            cellAux.addElement(foto1);
    	            tableaAux1.addCell(cellAux);
            	}
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }

        cellAux = new PdfPCell(new Phrase("Preferencias:", font));
        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cellAux.setBorder(PdfPCell.NO_BORDER);
        tableaAux1.addCell(cellAux);

        cellAux = new PdfPCell(new Phrase(validarTexto(beanMovilidad.getPreferenciaPais()), font));
        cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
        cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cellAux.setBorder(PdfPCell.NO_BORDER);
        tableaAux1.addCell(cellAux);
        
        /*
        if(tipoMovilidad.equals("SI")){
            cellAux = new PdfPCell(new Phrase("Preferencias:", font));
            cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
            cellAux.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            cellAux.setBorder(PdfPCell.NO_BORDER);
            tableaAux1.addCell(cellAux);

            cellAux = new PdfPCell(new Phrase(beanMovilidad.getPreferenciaPais(), font));
            cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
            cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            cellAux.setBorder(PdfPCell.NO_BORDER);
            tableaAux1.addCell(cellAux);
        }
        else{
            cellAux = new PdfPCell(new Phrase("", font));
            cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
            cellAux.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            cellAux.setBorder(PdfPCell.NO_BORDER);
            tableaAux1.addCell(cellAux);

            cellAux = new PdfPCell(new Phrase("", font));
            cellAux.setBackgroundColor(new BaseColor(255, 255, 255));
            cellAux.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            cellAux.setBorder(PdfPCell.NO_BORDER);
            tableaAux1.addCell(cellAux);
        }*/

        table.addCell(tableaAux1);

		//PRUEBA        

        return table;
    }
    
    private String validarTexto(String desc_competencia) {
        return desc_competencia.replace("@", "\n");
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
